#include "Octahedral.h"

void Octahedral::GetPoint()
{
	double a = 100;
	P[0].x = 0, P[0].y = a, P[0].z = 0, P[0].w = 1;
	P[1].x = 0, P[1].y = -a, P[1].z = 0, P[1].w = 1;
	P[2].x = a, P[2].y = 0, P[2].z = 0, P[2].w = 1;
	P[3].x = 0, P[3].y = 0, P[3].z = -a, P[3].w = 1;
	P[4].x = -a, P[4].y = 0, P[4].z = 0, P[4].w = 1;
	P[5].x = 0, P[5].y = 0, P[5].z = a, P[5].w = 1;
}

void Octahedral::GetFacet()
{
	F[0].Index[0] = 0, F[0].Index[1] = 5, F[0].Index[2] = 2;
	F[1].Index[0] = 0, F[1].Index[1] = 2, F[1].Index[2] = 3;
	F[2].Index[0] = 0, F[2].Index[1] = 3, F[2].Index[2] = 4;
	F[3].Index[0] = 0, F[3].Index[1] = 4, F[3].Index[2] = 5;
	F[4].Index[0] = 1, F[4].Index[1] = 5, F[4].Index[2] = 2;
	F[5].Index[0] = 1, F[5].Index[1] = 2, F[5].Index[2] = 3;
	F[6].Index[0] = 1, F[6].Index[1] = 3, F[6].Index[2] = 4;
	F[7].Index[0] = 1, F[7].Index[1] = 4, F[7].Index[2] = 5;

}

E_Point3* Octahedral::GetVertexArrayName()
{
	return P;
}

void Octahedral::Draw()
{
	E_Point ScreenPoint, temp;
	for (int nFace = 0; nFace < 8; nFace++) {
		for (int nPoints = 0; nPoints < 3; nPoints++) {
			ScreenPoint.x = P[F[nFace].Index[nPoints]].x;
			ScreenPoint.y = P[F[nFace].Index[nPoints]].y;
			if (nPoints == 0) {
				moveto(ScreenPoint.x, ScreenPoint.y);
				temp = ScreenPoint;
			}
			else {
				lineto(ScreenPoint.x, ScreenPoint.y);
			}
		}
		lineto(ScreenPoint.x, ScreenPoint.y);
	}
}
